package edu.langnan.xiaoli.config.web;

import edu.langnan.xiaoli.base.AjaxResult;
import edu.langnan.xiaoli.exception.BaseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author cql
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);


    /**
     * 基础异常
     */
    @ExceptionHandler(BaseException.class)
    public AjaxResult baseException(BaseException e) {
        log.error("baseException 出现异常 {}", e);
        return AjaxResult.error(e.getMessage());
    }


}
